#ifndef _PAPERS_H_
#define _PAPERS_H_

#include <string.h>
#include "consts.h"
#include "transfer.h"


struct paper_t {
  char author[MAX_AUTHOR_LENGTH];
  char title[MAX_TITLE_LENGTH];
  char file_name[MAX_FILE_NAME_LENGTH];  
  int id;
  int size;
  int complite;
  char * data;
};

struct papers_t {
  struct paper_t papers[MAX_PAPERS];
  int count;
  int next_id;
};

/* papers */
void papers_create(struct papers_t * papers);
int papers_count(struct papers_t * papers);
int papers_add(struct papers_t * papers, char * author, char * title, char * file_name);
void papers_dump(struct papers_t * papers);
int papers_get_last_id(struct papers_t * papers);

/* paper */
struct paper_t * get_paper_by_id(struct papers_t * papers, int id);
void paper_dump(struct paper_t * paper);
void paper_dump_data(struct paper_t * paper);
void paper_add_block(struct paper_t * paper, char * block, int size);
int paper_get_block(struct paper_t * paper, int block_no, char * block);

#endif
